<?php
	session_start();
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Service/ArticleService.php';
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/Context/BaseContext.php';
    require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../model/ServiceResult/ServiceResult.php';
    $articleService = new ArticleService();
   
	if(isset($_GET['code']) && isset($_GET['customerID']))
	{
		$context = new BaseContext();
		$result = new ServiceResult();
		$code = $_GET['code'];
		$customerID = $_GET['customerID'];
		$articleDomainArr = $articleService->getAllByCodeByCustomer($context, $result, $code, $customerID);
?>
	<script type="text/javascript">
		$(document).ready(function () {
			$("#autoCode tr:odd").css("background-color", "#ddd");
			$('#autoCode tr').click(function() {
				var tdCode = $(this).find("td").eq(0).html();        	
	        	$("input[name=code]").attr("value",$.trim(tdCode));
	        	$('#autoCode_wrap').remove();
			});
		});
	</script>
	<div id="autoCode_wrap">
		<table border="0" id="autoCode" width="100%" >
			<tr>
				<td>
					Code
				</td>
				<td>
					Description
				</td>
				<td>
					With X Height X Depth
				</td>
			</tr>
			<?php
				foreach ($articleDomainArr as $articleDomain)
				{
			?>
				<tr >
					<td>
						<?php echo $articleDomain->getCode(); ?>
					</td>
					<td>
						<?php echo $articleDomain->getDescription(); ?>
					</td>					
					<td align="center" >
						<?php echo $articleDomain->getWidth() . " X " . $articleDomain->getHeight() . " X " . $articleDomain->getDepth() ; ?>
					</td>
				</tr>
			<?php 
				}
			?>
		</table>
	</div>
<?php	
	}
?>
	